package kuangxiaoyang.hnevc.com.shijiebei.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import kuangxiaoyang.hnevc.com.shijiebei.R;
import kuangxiaoyang.hnevc.com.shijiebei.ShiJieBei;

/**
 * Created by Administrator on 2020/12/31.
 */

public class MyAdatper1 extends BaseAdapter {
    Context context;
    List<ShiJieBei.ResultBean> shijiebeilist;
    String TAG = "test";

    public MyAdatper1(Context context, List<ShiJieBei.ResultBean> shijiebeilist) {
        this.context = context;
        this.shijiebeilist = shijiebeilist;
    }

    @Override
    public int getCount() {
        return shijiebeilist.size();
    }

    @Override
    public Object getItem(int position) {
        return shijiebeilist.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.activity_item1,null);
        TextView textView1 = (TextView) convertView.findViewById(R.id.zubie_tv);
        TextView textView2 = (TextView) convertView.findViewById(R.id.guojia_tv);
        ImageView imageView1 = (ImageView) convertView.findViewById(R.id.tupian_im);
        textView1.setText(shijiebeilist.get(position).getId());
        textView2.setText(shijiebeilist.get(position).getName());
        String url = shijiebeilist.get(position).getUrl();
        int imgid = context.getResources().getIdentifier(url, "drawable", context.getPackageName());

        imageView1.setImageResource(imgid);
        return convertView;
    }
}
